package ru.spb.osll.myfit.common;

import java.io.Serializable;

import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * Table Cell Contains text of cell and result of testing
 * 
 * @author Akimushkin V.A.
 * 
 */
public class TableCell implements IsSerializable, Serializable {

	/**
	 * Serial version id
	 */
	private static final long serialVersionUID = 546722902087587861L;

	/**
	 * Cell text
	 */
	private String m_text = "";

	/**
	 * Cell tooltoptext
	 */
	private String m_tooltip = "";

	/**
	 * Result of testing
	 */
	private TableCellResult m_testResult = TableCellResult.NONE;

	/**
	 * Constructor
	 */
	public TableCell() {
	}

	/**
	 * Constructor
	 * 
	 * @param text
	 *            - text of cell
	 */
	public TableCell(String text) {
		m_text = text;
	}

	/**
	 * Get cell text
	 * 
	 * @return cell text
	 */
	public String getText() {
		return m_text;
	}

	/**
	 * Set cell text
	 * 
	 * @param text
	 *            - cell text
	 */
	public void setText(String text) {
		m_text = text;
	}

	/**
	 * Get cell tooltip
	 * 
	 * @return cell text
	 */
	public String getTooltip() {
		return m_tooltip;
	}

	/**
	 * Set cell tooltip
	 * 
	 * @param text
	 *            - cell text
	 */
	public void setTooltip(String text) {
		m_tooltip = text;
	}

	/**
	 * Get result of testing
	 * 
	 * @return result of testing
	 */
	public TableCellResult getTestResult() {
		return m_testResult;
	}

	/**
	 * Set result of testing
	 * 
	 * @param testResult
	 *            - result of testing
	 */
	public void setTestResult(TableCellResult testResult) {
		m_testResult = testResult;
	}

	@Override
	public boolean equals(Object other) {
		if (this == other)
			return true;
		if (other == null)
			return false;
		if (getClass() != other.getClass())
			return false;

		TableCell otherCell = (TableCell) other;
		if (getText().equals(otherCell.getText()))
			return true;
		else
			return false;
	}

	@Override
	public String toString() {
		return m_text;
	}
}
